<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>

<script type="text/javascript" charset="utf-8">
	
	var datagrid;//列表对象
	var number = '${param.number}';//判断是否为多选
		
	//var bianHao_inputName = '${param.bianHao_inputName}';
	//var mingCheng_inputName = '${param.mingCheng_inputName}';
	var single;
	
	/**
	*加载列表
	**/		
    $(function loadDatagrid() {
    	$('#selectInput').focus();
    	if(number==1){//单选框
			single = true;
		}else {//多选框
			single = false;
		}
		datagrid = $('#datagrid').datagrid({
			url : 'renWuJBXXAction!renWuDDatagrid.action',
			title : '',
			pagination : true,
			pageSize : 20,
			pageList : [ 10, 20, 30, 40 ],
			fit : true,
			fitColumns : true,
			nowrap : false,
			border : false,
			idField : 'bianHao',
			singleSelect : single,
			checkOnSelect : false,
			selectOnCheck : true,
			columns : [ [ //字段定义
	   		{
				title : '<s:text name="bianHao"></s:text>',
				field : 'bianHao',
				width : 50,
				sortable : true,
				checkbox : true
			}
			,{
				title : '<s:text name="heTongH"></s:text>',
				field : 'heTongH',
				width : 100
			}
			,{
				title : '<s:text name="qiYeMC"></s:text>',
				field : 'qiYeMC',
				width : 100
			}
			,{
				title : '<s:text name="yeWuZL"></s:text>',
				field : 'yeWuZLMC',
				width : 100
			}
			] ]
			,toolbar : [ {
				text : '<s:text name="select"></s:text>',
				iconCls : 'icon-edit',
				handler : function() {
					select();
				}
			}, '-']
			/*{
				text : '<s:text name="clean"></s:text>',
				iconCls : 'icon-cancel',
				handler : function() {
					clean();
				}
			}, '-']*/
		});
	});
	
	/**
	* 选择
	**/
	function select() {
		var d = share.data('renWuSelectDialog');
		//var f = d.find('form');
		var f = share.data('renWuSelectform');
		var renWuDGLBH = f.find('input[name=renWuDGLBH]');
		var renWuDGLMC = f.find('textarea[name=renWuDGLMC]');
		
		/*if(bianHao_inputName!=undefined&&bianHao_inputName!=''&&bianHao_inputName!=null){
			userID =  f.find('input[name='+bianHao_inputName+']');
		}
		if(mingCheng_inputName!=undefined&&mingCheng_inputName!=''&&mingCheng_inputName!=null){
			userName = f.find('input[name='+mingCheng_inputName+']');
		}*/
		
		var rows = datagrid.datagrid('getChecked');//获取选中行
		if(number==1){
			if(rows.length==1){
				renWuDGLBH.val(rows[0].bianHao);
				renWuDGLMC.val(rows[0].qiYeMC);
				share.removeData('renWuSelectform');
				share.removeData('renWuSelectDialog');
				d.dialog('close');
			} else if (rows.length > 1) {
				parent.dagong.messagerAlert('<s:text name="prompt"></s:text>', '<s:text name="PleaseChooseOnlyOneData"></s:text>', 'error');
			} else {
				parent.dagong.messagerAlert('<s:text name="prompt"></s:text>', '<s:text name="PleaseSelectARecord"></s:text>', 'error');
			}
		}
		if(number==2){
			if (rows.length >= 1) {
				var renWuDGLBHs=renWuDGLBH.val();
				var renWuDGLMCs=renWuDGLMC.val();
			//	alert(renWuDGLMCs);
				for(var i=0;i<rows.length;i++){
					if(renWuDGLBHs.length>0){
						renWuDGLBHs += "，";
						renWuDGLMCs += "，";
					}
					renWuDGLBHs += rows[i].bianHao;
					renWuDGLMCs += rows[i].qiYeMC;
				}
				renWuDGLBH.val(renWuDGLBHs);
				renWuDGLMC.val(renWuDGLMCs);
			//	renWuDGLMC.attr('value',renWuDGLMCs);
				share.removeData('renWuSelectform');
				share.removeData('renWuSelectDialog');
				d.dialog('close');
			} else {
				parent.dagong.messagerAlert('<s:text name="prompt"></s:text>', '<s:text name="PleaseSelectARecord"></s:text>', 'error');
			}
		}
		renWuDGLMC.focus();
	}
	
	/**
	* 提交查询
	**/
	function _search() {
		datagrid.datagrid('load', dagong.serializeObject($('#searchForm')));
	}
	
	/**
	* 清空查询条件
	**/
	function cleanSearch() {
		//datagrid.datagrid('load', {});
		//$('#searchForm input').val('');
		clean();
	}
	
	/**
	* 清除数据
	**/
	function clean() {
		var d = share.data('renWuSelectDialog');
		var f = share.data('renWuSelectform');
		var renWuDGLBH = f.find('input[name=renWuDGLBH]');
		var renWuDGLMC = f.find('textarea[name=renWuDGLMC]');
		
		/*if(bianHao_inputName!=undefined&&bianHao_inputName!=''&&bianHao_inputName!=null){
			userID =  f.find('input[name='+bianHao_inputName+']');
		}
		if(mingCheng_inputName!=undefined&&mingCheng_inputName!=''&&mingCheng_inputName!=null){
			userName = f.find('input[name='+mingCheng_inputName+']');
		}*/
		
		renWuDGLBH.val('');
		renWuDGLMC.val('');
		share.removeData('renWuSelectform');
		share.removeData('renWuSelectDialog');
		d.dialog('close');
		renWuDGLMC.focus();
	}
</script>
<div class="easyui-panel"style="width:500px;height:200px;padding:0px;background-color: white;" data-options="fit:true,border:false">
	<div class="easyui-layout" data-options="fit:true,border:false">	
		<div data-options="region:'north',border:false" style="height:60px;overflow:hidden;">
			<form id="searchForm" >
			
				<div style="padding:15px; margin: 0px; ">
	               	<span class="title">企业名称</span>
	               	<input id="selectInput" type="text" name="qiYeMC"  class="t_d"/>
	               	<!--<span class="title blankSpace">业务种类</span>
	               	<input type="text" name="yeWuZLMC" onclick="yeWuZLSelect()" class="t_d"/><input name="yeWuZLBH" type="hidden"/>-->
	               
	               	<a id="" class="easyui-linkbutton blankSpace" href="javascript:void(0)" onclick="_search();"><s:text name="query"></s:text></a>&nbsp;&nbsp;
	               	<a id="" class="easyui-linkbutton" href="javascript:void(0)" onclick="cleanSearch();"><s:text name="清除"></s:text></a>
			 	</div>
			
				<!--<div>
					<table class="tableForm datagrid-toolbar" style="width: 100%;height: 100%; padding: 10px;" >
						<tr>
							<td><s:text name="userName"></s:text></td>
							<td><input name="userName" style="width:200px;" /></td>
							<td><s:text name="ZuZhi"></s:text></td>
							<td><input name="zuZhiJGMC" style="width:200px;" /></td>
							<td>&nbsp;</td>
							<td align="center">
								<a href="javascript:void(0);" class="easyui-linkbutton" onclick="_search();"><s:text name="query"></s:text></a>
								<a href="javascript:void(0);" class="easyui-linkbutton" onclick="cleanSearch();"><s:text name="cancel"></s:text></a>
							</td>
						</tr>
					</table>
				</div>
				-->
			</form>
		</div>
		<div data-options="region:'center',border:false" data-options="fit:true">
			<table id="datagrid"></table>
		</div>
		<!--<div data-options="region:'south',border:false" align="right" data-options="fit:true">
			<a href="javascript:void(0);" class="easyui-linkbutton" onclick="clean();"><s:text name="clean"></s:text></a>
			<a href="javascript:void(0);" class="easyui-linkbutton" onclick="select();"><s:text name="select"></s:text></a>
		</div>
	--></div>
</div>

